home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / VTP031.ZIP;1 / VAPMU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-12-23  |  27.0 KB  |  1,400 lines

  1. {
  2. ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕ
  3.  
  4.  Visionix Advanced Power Management (VAPM) Unit
  5.    Version 0.7
  6.  Copyright 1991,92,93 Visionix
  7.  ALL RIGHTS RESERVED
  8.  
  9. ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
  10.  
  11.  Revision history in reverse chronological order:
  12.  
  13.  Initials  Date      Comment
  14.  --------  --------  -------------------------------------------------------
  15.  
  16.  jrt       10/27/93  Renamed from VAPM to VAPMU for beta 0.30
  17.  
  18.  mep       03/26/93  Rewritten and added many new functions.
  19.  
  20.  lpg       03/15/93  Added Source Documentation
  21.  
  22.  mep       02/11/93  Cleaned up code for beta release
  23.  
  24.  jrt       02/08/93  Sync with beta 0.12 release
  25.  
  26.  lpg       01/22/93  Wrote VAPMPresent and VPAMGetPowerStatus in ASM
  27.  
  28.  jrt       12/07/92  Sync with beta 0.11 release
  29.  
  30.  jrt       12/07/92  First logged revision.
  31.  
  32. ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕ
  33. }
  34.  
  35. (*-
  36.  
  37. [SECTION: Section 3: The Operating System Services Libraries]
  38. [CHAPTER: Chapter 1: The Advanced Power Management Unit]
  39.  
  40. [TEXT]
  41.  
  42. <Overview>
  43.  
  44. This unit is an interface to the DOS Advanced Power Management functions.
  45.  
  46. For more information, see the DOS Avanced Power Management
  47. specification which is available from Intel.
  48.  
  49. The documentation for this unit will be enhanced in the next BETA release.
  50.  
  51. <Interface>
  52.  
  53. -*)
  54.  
  55.  
  56. Unit VAPMU;
  57.  
  58. Interface
  59.  
  60. Uses
  61.  
  62.   VTypesu,
  63.   DOS,
  64.   VGenu;
  65.  
  66. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  67.  
  68. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  69.  
  70.  
  71. Const
  72.  
  73.   {-----------------------------}
  74.   { Generic error for functions }
  75.   {-----------------------------}
  76.  
  77.   apmError = $C8;
  78.  
  79.   {------------------------------------------------}
  80.   { Installation Flags - use with VAPMInstallCheck }
  81.   {------------------------------------------------}
  82.  
  83.   apmif16PModeAllowed     = 0; { 16-bit protected mode interface supported }
  84.   apmif32PModeAllowed     = 1; { 32-bit protected mode interface supported }
  85.   apmifCPUIdleSlower      = 2; { CPU idle decreases processor speed        }
  86.   apmifBIOSPowerManageOff = 3; { BIOS power management disabled            }
  87.  
  88.   {-----------------------------------------}
  89.   { Device IDs - use with VAPMSetPowerState }
  90.   {-----------------------------------------}
  91.  
  92.   apmidSysBIOS                = $0000;
  93.   apmidAllSysBIOSDevices      = $0001;
  94.   apmidDisplay                = $0100; { [00..FE] devices allowed }
  95.   apmidAllDisplay             = $01FF;
  96.   apmidSecStorage             = $0200; { [00..FE] devices allowed }
  97.   apmidSecStorageDevices      = $02FF;
  98.   apmidParallelPort           = $0300; { [00..FE] devices allowed }
  99.   apmidAllParallelPortDevices = $03FF;
  100.   apmidSerialPort             = $0400; { [00..FE] devices allowed }
  101.   apmidAllSerialPortDevices   = $04FF;
  102.  
  103.   {--------------------------------------------------}
  104.   { Set Power State IDs - use with VAPMSetPowerState }
  105.   {--------------------------------------------------}
  106.  
  107.   apmpsReady   = $0;
  108.   apmpsStandBy = $1;
  109.   apmpsSuspend = $2;
  110.   apmpsOff     = $3;
  111.  
  112.  
  113. Type
  114.  
  115.   TAPMError = BYTE;
  116.  
  117. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  118.  
  119. Function  VAPMErrorToStr(              ErrorCode      : TAPMError): STRING;
  120.  
  121. Function  VAPMInstalled                                           : BOOLEAN;
  122.  
  123. Procedure VAPMInstallCheck(        Var Version        : STRING;
  124.                                    Var Flags          : WORD;
  125.                                    Var ErrorCode      : TAPMError);
  126.  
  127. Function  VAPMConRealModeIntr                                     : TAPMError;
  128.  
  129. Function  VAPMCon16PModeInter(     Var RM16CodeSeg    : WORD;
  130.                                    Var EntryOfs       : WORD;
  131.                                    Var RM16DataSeg    : WORD    ) : TAPMError;
  132.  
  133. Function  VAPMCon32PModeInter(     Var RM32CodeSeg    : WORD;
  134.                                    Var EntryOfs       : LONGINT;
  135.                                    Var RM16CodeSeg    : WORD;
  136.                                    Var RM16DataSeg    : WORD    ) : TAPMError;
  137.  
  138. Function  VAPMDisConInter                                         : TAPMError;
  139.  
  140. Function  VAPMCPUIdle                                             : TAPMError;
  141.  
  142. Function  VAPMCPUBusy                                             : TAPMError;
  143.  
  144. Function  VAPMSetPowerState(           DeviceID       : WORD;
  145.                                        State          : WORD    ) : TAPMError;
  146.  
  147. Function  VAPMSysStandby                                          : TAPMError;
  148.  
  149. Function  VAPMSuspendSys                                          : TAPMError;
  150.  
  151. Function  VAPMSetPowerManager(         OnOff          : BOOLEAN ) : TAPMError;
  152.  
  153. Function  VAPMResetAsPowerOn                                      : TAPMError;
  154.  
  155. Function  VAPMGetPowerStatus(      Var ACLineStatus   : WORD;
  156.                                    Var BatteryStatus  : WORD;
  157.                                    Var BatteryPercent : WORD    ) : TAPMError;
  158.  
  159. Function  VAPMGetACLineStatus                                     : WORD;
  160.  
  161. Function  VAPMGetBatteryStatus                                    : WORD;
  162.  
  163. Function  VAPMGetBatteryPercent                                   : WORD;
  164.  
  165. Function  VAPMGetACLineStatusText                                 : STRING;
  166.  
  167. Function  VAPMGetBatteryStatusText                                : STRING;
  168.  
  169. Function  VAPMGetPowerEvent(       Var Event          : WORD    ) : TAPMError;
  170.  
  171. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  172.  
  173. Implementation
  174.  
  175. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  176.  
  177. (*-
  178.  
  179. [FUNCTION]
  180.  
  181. Function  VAPMErrorToStr(              ErrorCode      : TAPMError ) : STRING;
  182.  
  183. [PARAMETERS]
  184.  
  185. ErrorCode   APM Error code
  186.  
  187. [RETURNS]
  188.  
  189. String
  190.  
  191. [DESCRIPTION]
  192.  
  193. Converts APM errorcodes to string format.
  194.  
  195. [SEE-ALSO]
  196.  
  197. [EXAMPLE]
  198.  
  199. -*)
  200.  
  201. Function  VAPMErrorToStr(              ErrorCode      : TAPMError ) : STRING;
  202.  
  203. Var
  204.  
  205.   S : STRING;
  206.  
  207. BEGIN
  208.  
  209.   S := '';
  210.  
  211.   Case ErrorCode of
  212.  
  213.     $01 : S := 'Power management functionality disabled';
  214.     $02 : S := 'Interface connection already in effect';
  215.     $03 : S := 'Interface not connected';
  216.     $04 : S := 'Real-mode interface not connected';
  217.     $05 : S := '16-bit protected-mode already connected';
  218.     $06 : S := '16-bit protected-mode not supported';
  219.     $07 : S := '32-bit protected-mode already connected';
  220.     $08 : S := '32-bit protected-mode not supported';
  221.     $09 : S := 'Unrecognized device ID';
  222.     $0A : S := 'Invalid value for state parameter';
  223.     $60 : S := 'Can not enter requested state';
  224.     $80 : S := 'No power management events pending';
  225.     $86 : S := 'APM not present';
  226.     $87..$9F : S := 'Reserved for other power management event errors';
  227.     $0B..$1F : S := 'Reserved for other interface and general errors';
  228.     $20..$3F : S := 'Reserved for CPU errors';
  229.     $40..$5F : S := 'Reserved for device errors';
  230.     $61..$7F : S := 'Reserved for other system errors';
  231.     $81..$85 : S := 'Reserved for other power management event errors';
  232.  
  233.   End;
  234.  
  235.   VAPMErrorToStr := S;
  236.  
  237. END;
  238.  
  239. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  240.  
  241. (*-
  242.  
  243. [FUNCTION]
  244.  
  245. Function  VAPMInstalled                                         : BOOLEAN;
  246.  
  247. [PARAMETERS]
  248.  
  249. (none)
  250.  
  251. [RETURNS]
  252.  
  253. TRUE  if an APM manager can be found,
  254. FALSE if an APM manager can NOT be found.
  255.  
  256. [DESCRIPTION]
  257.  
  258. Checks to see if an APM manager is installed.
  259.  
  260. [SEE-ALSO]
  261.  
  262. [EXAMPLE]
  263.  
  264. -*)
  265.  
  266. Function  VAPMInstalled                                         : BOOLEAN;
  267.  
  268. Var
  269.  
  270.   R : REGISTERS;
  271.  
  272. BEGIN
  273.  
  274.   R.AX := $5300;
  275.   R.BX := $0000;
  276.   R.DS := 0;
  277.   R.ES := 0;
  278.  
  279.   Intr( $15, R );
  280.  
  281.   VAPMInstalled := ( R.AH <> $86 );
  282.  
  283. END;  { VAPMInstalled }
  284.  
  285. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  286.  
  287. (*-
  288.  
  289. [FUNCTION]
  290.  
  291. Procedure VAPMInstallCheck(        Var Version        : STRING;
  292.                                    Var Flags          : WORD;
  293.                                    Var ErrorCode      : TAPMError );
  294.  
  295. [PARAMETERS]
  296.  
  297. (none)
  298.  
  299. [RETURNS]
  300.  
  301. Version     Version of APM.
  302. Flags       Support flags of APM (see Installation Flags)
  303. ErrorCode   Condition of APM (active or not present).
  304.  
  305. [DESCRIPTION]
  306.  
  307. This function returns information about the APM manager.
  308.  
  309. The flags field will return any combination of the following values:
  310.  
  311.   apmif16PModeAllowed     = 0; { 16-bit protected mode interface supported }
  312.   apmif32PModeAllowed     = 1; { 32-bit protected mode interface supported }
  313.   apmifCPUIdleSlower      = 2; { CPU idle decreases processor speed        }
  314.   apmifBIOSPowerManageOff = 3; { BIOS power management disabled            }
  315.  
  316. [SEE-ALSO]
  317.  
  318. [EXAMPLE]
  319.  
  320. -*)
  321.  
  322. Procedure VAPMInstallCheck(        Var Version        : STRING;
  323.                                    Var Flags          : WORD;
  324.                                    Var ErrorCode      : TAPMError );
  325.  
  326. Var
  327.  
  328.   R : REGISTERS;
  329.  
  330. BEGIN
  331.  
  332.   R.AX := $5300;
  333.   R.BX := $0000;
  334.   R.DS := $0;
  335.   R.ES := $0;
  336.  
  337.   Intr( $15, R );
  338.  
  339.   If (R.Flags AND FCarry <> 0) Then
  340.   BEGIN
  341.  
  342.     ErrorCode := R.AH;
  343.  
  344.   END
  345.   Else
  346.   BEGIN
  347.  
  348.     Version   := IntToStr(BCDtoDec(R.AH)) + '.' +
  349.                  IntToStr(BCDtoDec(R.AL));
  350.     Flags     := R.CX;
  351.     ErrorCode := 0;
  352.  
  353.   END;
  354.  
  355. END;
  356.  
  357. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  358.  
  359. (*-
  360.  
  361. [FUNCTION]
  362.  
  363. Function  VAPMConRealModeIntr                                     : TAPMError;
  364.  
  365. [PARAMETERS]
  366.  
  367. (none)
  368.  
  369. [RETURNS]
  370.  
  371. Condition of interface.
  372.  
  373. [DESCRIPTION]
  374.  
  375. Makes a connection to the real-mode interface. Checks using the device ID of
  376. the system BIOS.
  377.  
  378. [SEE-ALSO]
  379.  
  380. [EXAMPLE]
  381.  
  382. -*)
  383.  
  384. Function  VAPMConRealModeIntr                                     : TAPMError;
  385.  
  386. Var
  387.  
  388.   R : REGISTERS;
  389.  
  390. BEGIN
  391.  
  392.   R.AX := $5301;
  393.   R.BX := $0000;
  394.   R.DS := $0;
  395.   R.ES := $0;
  396.  
  397.   Intr( $15, R );
  398.  
  399.   If (R.Flags AND FCarry <> 0) Then
  400.   BEGIN
  401.  
  402.     VAPMConRealModeIntr := R.AH;
  403.  
  404.   END
  405.   Else
  406.   BEGIN
  407.  
  408.     VAPMConRealModeIntr := 0;
  409.  
  410.   END;
  411.  
  412. END;
  413.  
  414. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  415.  
  416. (*-
  417.  
  418. [FUNCTION]
  419.  
  420. Function  VAPMCon16PModeInter(     Var RM16CodeSeg    : WORD;
  421.                                    Var EntryOfs       : WORD;
  422.                                    Var RM16DataSeg    : WORD    ) : TAPMError;
  423.  
  424. [PARAMETERS]
  425.  
  426. (none)
  427.  
  428. [RETURNS]
  429.  
  430. RM16CodeSeg  Real-mode segment base address of the protected-mode 16-bit code
  431.              segment.
  432. EntryOfs     Offset of entry point.
  433. RM16DataSeg  Real-mode segment base address of the protected-mode 16-bit data
  434.              segment.
  435.  
  436. [DESCRIPTION]
  437.  
  438. Makes a connection to the 16-bit protected-mode interface.  The caller must
  439. initialize two consecutive descriptors with the returned segment base
  440. addresses; these descriptors must be valid whenever the protected-mode
  441. interface is called, and will have their limits arbitrarily set to 64K.
  442.  
  443. The protected mode interface is invoked by making a far call with the same
  444. register values as for INT 15; it must be invoked while CPL=0, the code
  445. segment descriptor must have a DPL of 0, the stack must be in a 16-bit
  446. segment and have enough room for BIOS use and possible interrupts, and the
  447. current I/O permission bit map must allow access to the I/O ports used for
  448. power management.
  449.  
  450. [SEE-ALSO]
  451.  
  452. [EXAMPLE]
  453.  
  454. -*)
  455.  
  456. Function  VAPMCon16PModeInter(     Var RM16CodeSeg    : WORD;
  457.                                    Var EntryOfs       : WORD;
  458.                                    Var RM16DataSeg    : WORD    ) : TAPMError;
  459.  
  460. Var
  461.  
  462.   R : REGISTERS;
  463.  
  464. BEGIN
  465.  
  466.   R.AX := $5302;
  467.   R.BX := $0000;
  468.   R.DS := $0;
  469.   R.ES := $0;
  470.  
  471.   Intr( $15, R );
  472.  
  473.   If (R.Flags AND FCarry <> 0) Then
  474.   BEGIN
  475.  
  476.     VAPMCon16PModeInter := R.AH;
  477.  
  478.   END
  479.   Else
  480.   BEGIN
  481.  
  482.     VAPMCon16PModeInter := 0;
  483.  
  484.   END;
  485.  
  486. END;
  487.  
  488. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  489.  
  490. (*-
  491.  
  492. [FUNCTION]
  493.  
  494. Function  VAPMCon32PModeInter(     Var RM32CodeSeg    : WORD;
  495.                                    Var EntryOfs       : LONGINT;
  496.                                    Var RM16CodeSeg    : WORD;
  497.                                    Var RM16DataSeg    : WORD    ) : TAPMError;
  498.  
  499. [PARAMETERS]
  500.  
  501. (none)
  502.  
  503. [RETURNS]
  504.  
  505. RM32CodeSeg  Real-mode segment base address of protected-mode 32-bit code
  506.              segment.
  507. EntryOfs     Offset of entry point.
  508. RM16CodeSeg  Real-mode segment base address of protected-mode 16-bit code
  509.              segment.
  510. RM16DataSeg  Real-mode segment base address of protected-mode 16-bit data
  511.              segment.
  512.  
  513. [DESCRIPTION]
  514.  
  515. Makes a connection to the 32-bit protected-mode interface.  The caller must
  516. initialize three consecutive descriptors with the returned segment base
  517. addresses for 32-bit code, 16-bit code, and 16-bit data, respectively; these
  518. descriptors must be valid whenever the protected-mode interface is called,
  519. and will have their limits arbitrarily set to 64K.
  520.  
  521. The protected mode interface is invoked by making a far call to the 32-bit
  522. code segment with the same register values as for INT 15; it must be invoked
  523. while CPL=0, the code segment descriptor must have a DPL of 0, the stack must
  524. be in a 32-bit segment and have enough room for BIOS use and possible
  525. interrupts, and the current I/O permission bit map must allow access to the
  526. I/O ports used for power management.
  527.  
  528. [SEE-ALSO]
  529.  
  530. [EXAMPLE]
  531.  
  532. -*)
  533.  
  534. Function  VAPMCon32PModeInter(     Var RM32CodeSeg    : WORD;
  535.                                    Var EntryOfs       : LONGINT;
  536.                                    Var RM16CodeSeg    : WORD;
  537.                                    Var RM16DataSeg    : WORD    ) : TAPMError;
  538.  
  539. Var
  540.  
  541.   R : REGISTERS;
  542.  
  543. BEGIN
  544.  
  545.   R.AX := $5303;
  546.   R.BX := $0000;
  547.   R.DS := $0;
  548.   R.ES := $0;
  549.  
  550.   Intr( $15, R );
  551.  
  552.   If (R.Flags AND FCarry <> 0) Then
  553.   BEGIN
  554.  
  555.     VAPMCon32PModeInter := R.AH;
  556.  
  557.   END
  558.   Else
  559.   BEGIN
  560.  
  561.     VAPMCon32PModeInter := 0;
  562.  
  563.   END;
  564.  
  565. END;
  566.  
  567. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  568.  
  569. (*-
  570.  
  571. [FUNCTION]
  572.  
  573. Function  VAPMDisConInter                                         : TAPMError;
  574.  
  575. [PARAMETERS]
  576.  
  577. (none)
  578.  
  579. [RETURNS]
  580.  
  581. Condition of APM connection.
  582.  
  583. [DESCRIPTION]
  584.  
  585. Disconnects the installed APM interface using the device ID of the system
  586. BIOS.
  587.  
  588. [SEE-ALSO]
  589.  
  590. [EXAMPLE]
  591.  
  592. -*)
  593.  
  594. Function  VAPMDisConInter                                         : TAPMError;
  595.  
  596. Var
  597.  
  598.   R : REGISTERS;
  599.  
  600. BEGIN
  601.  
  602.   R.AX := $5304;
  603.   R.BX := $0000;
  604.   R.DS := $0;
  605.   R.ES := $0;
  606.  
  607.   Intr( $15, R );
  608.  
  609.   If (R.Flags AND FCarry <> 0) Then
  610.   BEGIN
  611.  
  612.     VAPMDisConInter := R.AH;
  613.  
  614.   END
  615.   Else
  616.   BEGIN
  617.  
  618.     VAPMDisConInter := 0;
  619.  
  620.   END;
  621.  
  622. END;
  623.  
  624. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  625.  
  626. (*-
  627.  
  628. [FUNCTION]
  629.  
  630. Function  VAPMCPUIdle                                             : TAPMError;
  631.  
  632. [PARAMETERS]
  633.  
  634. (none)
  635.  
  636. [RETURNS]
  637.  
  638. (clear)
  639.  
  640. [DESCRIPTION]
  641.  
  642. Places the CPU into idle state.  Call this when the system is idle and
  643. should be suspended until the next system event or interrupt.  Also, if an
  644. interrupt causes the system to resume normal processing, the interrupt may
  645. or may not have been handled when the BIOS returns from this call; thus,
  646. the caller should allow interrupts on return.
  647.  
  648. Interrupt handlers may not retain control if the BIOS allows interrupts while
  649. in idle mode even if they are able to determine that they were called from
  650. idle mode.  The caller should issue this call continuously in a loop until
  651. it needs to perform some processing of its own.
  652.  
  653. [SEE-ALSO]
  654.  
  655. [EXAMPLE]
  656.  
  657. -*)
  658.  
  659. Function  VAPMCPUIdle                                             : TAPMError;
  660.  
  661. Var
  662.  
  663.   R : REGISTERS;
  664.  
  665. BEGIN
  666.  
  667.   R.AX := $5305;
  668.   R.DS := $0;
  669.   R.ES := $0;
  670.  
  671.   Intr( $15, R );
  672.  
  673.   VAPMCPUIdle := 0;
  674.  
  675. END;
  676.  
  677. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  678.  
  679. (*-
  680.  
  681. [FUNCTION]
  682.  
  683. Function  VAPMCPUBusy                                             : TAPMError;
  684.  
  685. [PARAMETERS]
  686.  
  687. (none)
  688.  
  689. [RETURNS]
  690.  
  691. (clear)
  692.  
  693. [DESCRIPTION]
  694.  
  695. Places the CPU into a busy state.  This is called to ensure that the system
  696. runs at full speed even on systems where the BIOS is unable to recognize
  697. increased activity (especially if interrupts are hooked by other programs and
  698. not chained to the BIOS).  This call may be made even when the system is
  699. already running at full speed, but it will create unnecessary overhead.
  700.  
  701. [SEE-ALSO]
  702.  
  703. [EXAMPLE]
  704.  
  705. -*)
  706.  
  707. Function  VAPMCPUBusy                                             : TAPMError;
  708.  
  709. Var
  710.  
  711.   R : REGISTERS;
  712.  
  713. BEGIN
  714.  
  715.   R.AX := $5306;
  716.   R.DS := $0;
  717.   R.ES := $0;
  718.  
  719.   Intr( $15, R );
  720.  
  721.   VAPMCPUBusy := 0;
  722.  
  723. END;
  724.  
  725. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  726.  
  727. (*-
  728.  
  729. [FUNCTION]
  730.  
  731. Function  VAPMSetPowerState(           DeviceID       : WORD;
  732.                                        State          : WORD    ) : TAPMError;
  733.  
  734. [PARAMETERS]
  735.  
  736. DeviceID     Device ID to apply new power state (see Device IDs).
  737. State        New power state for device (see Set Power State IDs).
  738.  
  739. [RETURNS]
  740.  
  741. Result of function.
  742.  
  743. [DESCRIPTION]
  744.  
  745. Sets the system state for a specific device.
  746.  
  747. [SEE-ALSO]
  748.  
  749. [EXAMPLE]
  750.  
  751. -*)
  752.  
  753. Function  VAPMSetPowerState(           DeviceID       : WORD;
  754.                                        State          : WORD    ) : TAPMError;
  755.  
  756. Var
  757.  
  758.   R : REGISTERS;
  759.  
  760. BEGIN
  761.  
  762.   R.AX := $5307;
  763.   R.BX := DeviceID;
  764.   R.CX := State;
  765.   R.DS := $0;
  766.   R.ES := $0;
  767.  
  768.   Intr( $15, R );
  769.  
  770.   If (R.Flags AND FCarry <> 0) Then
  771.   BEGIN
  772.  
  773.     VAPMSetPowerState := R.AH;
  774.  
  775.   END
  776.   Else
  777.   BEGIN
  778.  
  779.     VAPMSetPowerState := 0;
  780.  
  781.   END;
  782.  
  783. END;
  784.  
  785. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  786.  
  787. (*-
  788.  
  789. [FUNCTION]
  790.  
  791. Function  VAPMSysStandby                                          : TAPMError;
  792.  
  793. [PARAMETERS]
  794.  
  795. (none)
  796.  
  797. [RETURNS]
  798.  
  799. (clear)
  800.  
  801. [DESCRIPTION]
  802.  
  803. Puts the entire system into stand-by mode; normally called in response to a
  804. System Stand-by Request notification after any necessary processing, but may
  805. also be invoked at the caller's discretion.
  806.  
  807. The stand-by state is typically exited on an interrupt.
  808.  
  809. [SEE-ALSO]
  810.  
  811. [EXAMPLE]
  812.  
  813. -*)
  814.  
  815. Function  VAPMSysStandby                                          : TAPMError;
  816.  
  817. Var
  818.  
  819.   R : REGISTERS;
  820.  
  821. BEGIN
  822.  
  823.   R.AX := $5307;
  824.   R.BX := $0001;
  825.   R.CX := $0001;
  826.   R.DS := $0;
  827.   R.ES := $0;
  828.  
  829.   Intr( $15, R );
  830.  
  831.   VAPMSysStandby := 0;
  832.  
  833. END;
  834.  
  835. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  836.  
  837. (*-
  838.  
  839. [FUNCTION]
  840.  
  841. Function  VAPMSuspendSys                                          : TAPMError;
  842.  
  843. [PARAMETERS]
  844.  
  845. (none)
  846.  
  847. [RETURNS]
  848.  
  849. (clear)
  850.  
  851. [DESCRIPTION]
  852.  
  853. Puts the entire system into a low-power suspended state; normally called in
  854. response to a Suspend System Request notification after any necessary
  855. processing, but may also be invoked at the caller's discretion.  The caller
  856. may need to update its date and time values because the system could have
  857. been suspended for a long period of time.
  858.  
  859. [SEE-ALSO]
  860.  
  861. [EXAMPLE]
  862.  
  863. -*)
  864.  
  865. Function  VAPMSuspendSys                                          : TAPMError;
  866.  
  867. Var
  868.  
  869.   R : REGISTERS;
  870.  
  871. BEGIN
  872.  
  873.   R.AX := $5307;
  874.   R.BX := $0001;
  875.   R.CX := $0002;
  876.   R.DS := $0;
  877.   R.ES := $0;
  878.  
  879.   Intr( $15, R );
  880.  
  881.   VAPMSuspendSys := 0;
  882.  
  883. END;
  884.  
  885. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  886.  
  887. (*-
  888.  
  889. [FUNCTION]
  890.  
  891. Function  VAPMSetPowerManager(         OnOff          : BOOLEAN ) : TAPMError;
  892.  
  893. [PARAMETERS]
  894.  
  895. OnOff        Condition to put APM into.
  896.  
  897. [RETURNS]
  898.  
  899. APM errorcode.
  900.  
  901. [DESCRIPTION]
  902.  
  903. When power management is disabled, the system BIOS will not automatically
  904. power down devices, enter stand-by or suspended mode, or perform any
  905. power-saving actions in response to CPU idle calls.
  906.  
  907. [SEE-ALSO]
  908.  
  909. [EXAMPLE]
  910.  
  911. -*)
  912.  
  913. Function  VAPMSetPowerManager(         OnOff          : BOOLEAN ) : TAPMError;
  914.  
  915. Var
  916.  
  917.   R : REGISTERS;
  918.  
  919. BEGIN
  920.  
  921.   R.AX := $5308;
  922.   R.BX := $FFFF;
  923.   R.CX := Byte(OnOff);
  924.   R.DS := $0;
  925.   R.ES := $0;
  926.  
  927.   Intr( $15, R );
  928.  
  929.   If (R.Flags AND FCarry <> 0) Then
  930.   BEGIN
  931.  
  932.     VAPMSetPowerManager := R.AH;
  933.  
  934.   END
  935.   Else
  936.   BEGIN
  937.  
  938.     VAPMSetPowerManager := 0;
  939.  
  940.   END;
  941.  
  942. END;
  943.  
  944. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  945.  
  946. (*-
  947.  
  948. [FUNCTION]
  949.  
  950. Function  VAPMResetAsPowerOn                                      : TAPMError;
  951.  
  952. [PARAMETERS]
  953.  
  954. (none)
  955.  
  956. [RETURNS]
  957.  
  958. Condition of function.
  959.  
  960. [DESCRIPTION]
  961.  
  962. Restores power-on defaults for the APM.
  963.  
  964. [SEE-ALSO]
  965.  
  966. [EXAMPLE]
  967.  
  968. -*)
  969.  
  970. Function  VAPMResetAsPowerOn                                      : TAPMError;
  971.  
  972. Var
  973.  
  974.   R : REGISTERS;
  975.  
  976. BEGIN
  977.  
  978.   R.AX := $5309;
  979.   R.BX := $FFFF;
  980.   R.DS := $0;
  981.   R.ES := $0;
  982.  
  983.   Intr( $15, R );
  984.  
  985.   If (R.Flags AND FCarry <> 0) Then
  986.   BEGIN
  987.  
  988.     VAPMResetAsPowerOn := R.AH;
  989.  
  990.   END
  991.   Else
  992.   BEGIN
  993.  
  994.     VAPMResetAsPowerOn := 0;
  995.  
  996.   END;
  997.  
  998. END;
  999.  
  1000. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1001.  
  1002. (*-
  1003.  
  1004. [FUNCTION]
  1005.  
  1006. Function  VAPMGetPowerStatus(      Var ACLineStatus   : WORD;
  1007.                                    Var BatteryStatus  : WORD;
  1008.                                    Var BatteryPercent : WORD    ) : TAPMError;
  1009.  
  1010. [PARAMETERS]
  1011.  
  1012. (none)
  1013.  
  1014. [RETURNS]
  1015.  
  1016. ACLineStatus   Status of A/C power supply.
  1017. BatteryStatus  Status of the battery supply.
  1018. BatteryPercent Percentage of remaining battery life.
  1019.  
  1020. [DESCRIPTION]
  1021.  
  1022. Gets status of power supply from APM.
  1023.  
  1024. [SEE-ALSO]
  1025.  
  1026. [EXAMPLE]
  1027.  
  1028. -*)
  1029.  
  1030. Function  VAPMGetPowerStatus(      Var ACLineStatus   : WORD;
  1031.                                    Var BatteryStatus  : WORD;
  1032.                                    Var BatteryPercent : WORD    ) : TAPMError;
  1033.  
  1034. Var
  1035.  
  1036.   R : REGISTERS;
  1037.  
  1038. BEGIN
  1039.  
  1040.   R.AX := $530A;
  1041.   R.BX := $0001;
  1042.   R.DS := 0;
  1043.   R.ES := 0;
  1044.  
  1045.   Intr( $15, R );
  1046.  
  1047.   If (R.Flags AND FCarry <> 0) Then
  1048.   BEGIN
  1049.  
  1050.     VAPMGetPowerStatus := R.AH;
  1051.  
  1052.   END
  1053.   Else
  1054.   BEGIN
  1055.  
  1056.     ACLineStatus       := R.BH;
  1057.     BatteryStatus      := R.BL;
  1058.     BatteryPercent     := R.CX;
  1059.     VAPMGetPowerStatus := 0;
  1060.  
  1061.   END;
  1062.  
  1063. END;  { VAPMGetPowerStatus }
  1064.  
  1065. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1066.  
  1067. (*-
  1068.  
  1069. [FUNCTION]
  1070.  
  1071. Function VAPMGetACLineStatus                                  : WORD;
  1072.  
  1073. [PARAMETERS]
  1074.  
  1075. (none)
  1076.  
  1077. [RETURNS]
  1078.  
  1079. Status of A/C line.
  1080.  
  1081. [DESCRIPTION]
  1082.  
  1083. Returns condition of A/C line power supply.
  1084.  
  1085. [SEE-ALSO]
  1086.  
  1087. [EXAMPLE]
  1088.  
  1089. -*)
  1090.  
  1091. Function VAPMGetACLineStatus                                  : WORD;
  1092.  
  1093. Var
  1094.  
  1095.   ACStat  : WORD;
  1096.   BatStat : WORD;
  1097.   BatPer  : WORD;
  1098.   Err     : TAPMError;
  1099.  
  1100. BEGIN
  1101.  
  1102.   Err := VAPMGetPowerStatus( ACStat, BatStat, BatPer );
  1103.   If (Err <> 0) Then
  1104.     VAPMGetACLineStatus := apmError
  1105.   Else
  1106.     VAPMGetACLineStatus := ACStat;
  1107.  
  1108. END;  { VAPMGetACLineStatus }
  1109.  
  1110. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1111.  
  1112. (*-
  1113.  
  1114. [FUNCTION]
  1115.  
  1116. Function VAPMGetBatteryStatus                                 : WORD;
  1117.  
  1118. [PARAMETERS]
  1119.  
  1120. (none)
  1121.  
  1122. [RETURNS]
  1123.  
  1124. Status of Battery.
  1125.  
  1126. [DESCRIPTION]
  1127.  
  1128. Returns condition of battery supply.
  1129.  
  1130. [SEE-ALSO]
  1131.  
  1132. [EXAMPLE]
  1133.  
  1134. -*)
  1135.  
  1136. Function VAPMGetBatteryStatus                                 : WORD;
  1137.  
  1138. Var
  1139.  
  1140.   ACStat  : WORD;
  1141.   BatStat : WORD;
  1142.   BatPer  : WORD;
  1143.   Err     : TAPMError;
  1144.  
  1145. BEGIN
  1146.  
  1147.   Err := VAPMGetPowerStatus( ACStat, BatStat, BatPer );
  1148.   If (Err <> 0) Then
  1149.     VAPMGetBatteryStatus := apmError
  1150.   Else
  1151.     VAPMGetBatteryStatus := BatStat;
  1152.  
  1153. END;  { VAPMGetBatteryStatus }
  1154.  
  1155. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1156.  
  1157. (*-
  1158.  
  1159. [FUNCTION]
  1160.  
  1161. Function VAPMGetBatteryPercent                                : WORD;
  1162.  
  1163. [PARAMETERS]
  1164.  
  1165. (none)
  1166.  
  1167. [RETURNS]
  1168.  
  1169. Percentage of battery.
  1170.  
  1171. [DESCRIPTION]
  1172.  
  1173. Returns the percentage of remaining battery life.
  1174.  
  1175. [SEE-ALSO]
  1176.  
  1177. [EXAMPLE]
  1178.  
  1179. -*)
  1180.  
  1181. Function VAPMGetBatteryPercent                                : WORD;
  1182.  
  1183. Var
  1184.  
  1185.   ACStat  : WORD;
  1186.   BatStat : WORD;
  1187.   BatPer  : WORD;
  1188.   Err     : TAPMError;
  1189.  
  1190. BEGIN
  1191.  
  1192.   Err := VAPMGetPowerStatus( ACStat, BatStat, BatPer );
  1193.   If (Err <> 0) Then
  1194.     VAPMGetBatteryPercent := apmError
  1195.   Else
  1196.     VAPMGetBatteryPercent := BatPer;
  1197.  
  1198. END;  { VAPMGetBatteryPower }
  1199.  
  1200. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1201.  
  1202. (*-
  1203.  
  1204. [FUNCTION]
  1205.  
  1206. [PARAMETERS]
  1207.  
  1208. [RETURNS]
  1209.  
  1210. [DESCRIPTION]
  1211.  
  1212. [SEE-ALSO]
  1213.  
  1214. [EXAMPLE]
  1215.  
  1216. -*)
  1217.  
  1218. Function VAPMGetACLineStatusText                              : STRING;
  1219.  
  1220. Var
  1221.  
  1222.   S : STRING;
  1223.  
  1224. BEGIN
  1225.  
  1226.   S := '';
  1227.  
  1228.   Case VAPMGetACLineStatus of
  1229.  
  1230.     $00 : S := 'Off-line (running from battery)';
  1231.     $01 : S := 'On-line  (running from AC line)';
  1232.     $FF : S := '(unknown)';
  1233.  
  1234.   ELSE
  1235.  
  1236.     S := '(error/unknown)';
  1237.  
  1238.   END;  { Case VAPMGetACLineStatus }
  1239.  
  1240.   VAPMGetACLineStatusText := S;
  1241.  
  1242. END;  { VAPMGetACLineStatusText }
  1243.  
  1244. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1245.  
  1246. (*-
  1247.  
  1248. [FUNCTION]
  1249.  
  1250. [PARAMETERS]
  1251.  
  1252. [RETURNS]
  1253.  
  1254. [DESCRIPTION]
  1255.  
  1256. [SEE-ALSO]
  1257.  
  1258. [EXAMPLE]
  1259.  
  1260. -*)
  1261.  
  1262. Function VAPMGetBatteryStatusText                             : STRING;
  1263.  
  1264. Var
  1265.  
  1266.   S : STRING;
  1267.  
  1268. BEGIN
  1269.  
  1270.   S := '';
  1271.  
  1272.   Case VAPMGetACLineStatus of
  1273.  
  1274.     $00 : S := 'High';
  1275.     $01 : S := 'Low';
  1276.     $02 : S := 'Critical';
  1277.     $03 : S := 'Charging';
  1278.     $FF : S := '(unknown)';
  1279.  
  1280.   ELSE
  1281.  
  1282.     S := '(error/unknown)';
  1283.  
  1284.   END;  { Case VAPMGetACLineStatus }
  1285.  
  1286.   VAPMGetBatteryStatusText := S;
  1287.  
  1288. END;  { VAPMGetBatteryStatusText }
  1289.  
  1290. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1291.  
  1292. (*-
  1293.  
  1294. [FUNCTION]
  1295.  
  1296. [PARAMETERS]
  1297.  
  1298. [RETURNS]
  1299.  
  1300. [DESCRIPTION]
  1301.  
  1302. [SEE-ALSO]
  1303.  
  1304. [EXAMPLE]
  1305.  
  1306. -*)
  1307.  
  1308. Function  VAPMGetPowerEvent(       Var Event          : WORD    ) : TAPMError;
  1309.  
  1310. Var
  1311.  
  1312.   R : REGISTERS;
  1313.  
  1314. BEGIN
  1315.  
  1316.   R.AX := $530B;
  1317.   R.DS := $0;
  1318.   R.ES := $0;
  1319.  
  1320.   Intr( $15, R );
  1321.  
  1322.   If (R.Flags AND FCarry <> 0) Then
  1323.   BEGIN
  1324.  
  1325.     VAPMGetPowerEvent := R.AH;
  1326.  
  1327.   END
  1328.   Else
  1329.   BEGIN
  1330.  
  1331.     Event             := R.BX;
  1332.     VAPMGetPowerEvent := 0;
  1333.  
  1334.   END;
  1335.  
  1336. END;
  1337.  
  1338. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1339.  
  1340. (*-
  1341.  
  1342. [FUNCTION]
  1343.  
  1344. [PARAMETERS]
  1345.  
  1346. [RETURNS]
  1347.  
  1348. [DESCRIPTION]
  1349.  
  1350. [SEE-ALSO]
  1351.  
  1352. [EXAMPLE]
  1353.  
  1354. -*)
  1355.  
  1356. Function VAPMGetPowerEventText                                : STRING;
  1357.  
  1358. Var
  1359.  
  1360.   S     : STRING;
  1361.   Event : WORD;
  1362.   Err   : TAPMError;
  1363.  
  1364. BEGIN
  1365.  
  1366.   S   := '';
  1367.   Err := VAPMGetPowerEvent(Event);
  1368.  
  1369.   If (Err = 0) Then
  1370.   BEGIN
  1371.  
  1372.     Case Event of
  1373.  
  1374.       $01 : S := 'System stand-by request';
  1375.       $02 : S := 'System suspend request';
  1376.       $03 : S := 'Normal resume system notification';
  1377.       $04 : S := 'Critical resume system notification';
  1378.       $05 : S := 'Battery low notification';
  1379.  
  1380.     Else
  1381.  
  1382.       S := '(unknown)';
  1383.  
  1384.     END;
  1385.  
  1386.   END
  1387.   Else
  1388.     S := '(error)';
  1389.  
  1390.   VAPMGetPowerEventText := S;
  1391.  
  1392. END;  { VAPMGetPowerEventText }
  1393.  
  1394. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1395. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1396. {ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ}
  1397.  
  1398. BEGIN
  1399. END.
  1400.